package com.googlecode.jpocketmod.actions;

/**
 *
 * @author David Sosby
 */
public class ActionFactory {
	private static ActionFactory instance = null;
	
	private static ExitApplicationAction exitApplicationAction;
	private static LoadTemplateAction loadTemplateAction;
	private static SaveTemplateAction saveTemplateAction;
	private static CreatePageAction createPageAction;
	
	private ActionFactory()  {
	}
	
	public static ActionFactory getInstance()  {
		if ( instance == null )  {
			synchronized(ActionFactory.class)  {
				if ( instance == null )  {
					instance = new ActionFactory();
				}
			}
		}
		
		return instance;
	}
	
	public ApplicationAction getExitApplicationAction()  {
		if ( exitApplicationAction == null )  exitApplicationAction = new ExitApplicationAction();
		return exitApplicationAction;
	}
	
	public ApplicationAction getLoadTemplateAction()  {
		if ( loadTemplateAction == null )  loadTemplateAction = new LoadTemplateAction();
		return loadTemplateAction;
	}
	
	public ApplicationAction getSaveTemplateAction()  {
		if ( saveTemplateAction == null )  saveTemplateAction = new SaveTemplateAction();
		return saveTemplateAction;
	}
	
	public ApplicationAction getChoosePageAction(int pageIndex)  {
		return new ChoosePageAction(pageIndex);
	}
	
	public ApplicationAction getCreatePageAction()  {
		if ( createPageAction == null )  createPageAction = new CreatePageAction();
		return createPageAction;
	}
}
